package com.acme;

import java.io.IOException;

import com.acme.service.bank.*;
import com.acme.domain.account.SavingsAccount;
import com.acme.domain.bank.Bank;
import com.acme.domain.client.Client;
import com.acme.domain.client.Gender;
import com.acme.exceptions.ClientAlreadyExistsException;
import com.acme.exceptions.ClientCountLimitException;

class BankApplication {
	public static void main(String[] args) throws IOException, ClientAlreadyExistsException, ClientCountLimitException{
		String path = null;
		for (int i=0; i<args.length; i++) {
			if ("-loadfeed".equals(args[i]) ) {
				try {
					path = args[i+1];
				} catch (ArrayIndexOutOfBoundsException e) {
					throw new IOException("wrong command line input! (missing path after loadfeed");
				}
			}
		}
		
		Bank db = new Bank();
		BankService.loadBank(db, path);
		db.addClient(new Client(new SavingsAccount(50),Gender.MALE,"Sidorov"));
		BankService.saveBank(db, "outputfeed.txt");
	}
}